﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class FinanceCenter_FundListForPrint : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string StartTime = Request["StartTime"];
            string EndTime = Request["EndTime"];
            tbStartTime.Value = Shove._Convert.StrToDateTime(StartTime, DateTime.Now.ToShortDateString()).ToString();
            tbEndTime.Value = Shove._Convert.StrToDateTime(EndTime, DateTime.Now.ToShortDateString()).ToString();

            BindData();

            //Log log = new Log();
            //log.UserID = _User.ID;
            //log.Operate = _User.RealityName + "查看收入明细记录";
            //log.UserIp = _User.LoginIP;
            //log.EditLog();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
//        RequestCompetences = Competences.BuildCompetencesList(Competences.Finance);
        RequestLoginPage = this.Request.Url.AbsoluteUri;

        base.OnInit(e);
    }

    #endregion

    private void BindData()
    {
        DateTime StartTime = Shove._Convert.StrToDateTime(tbStartTime.Value.ToString(), DateTime.Now.ToShortDateString());
        DateTime EndTime = Shove._Convert.StrToDateTime(tbEndTime.Value.ToString(), DateTime.Now.ToShortDateString());

        string ReturnDescription = "";

        DataSet ds = null;

        DAL.Procedures.P_InComingOrOutComing(ref ds, StartTime, EndTime, 2, ref ReturnDescription);

        if (ds == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "数据库连接失败。");

            return;
        }

        g.DataSource = ds.Tables[0].DefaultView;
        g.DataBind();

        if (ds.Tables[1].Rows.Count > 0)
        {
            string strMoney = ds.Tables[1].Rows[0]["SumMoney"].ToString();
            lbUserCount.Text = ds.Tables[1].Rows[0]["SumID"].ToString();

            lbBuyCount.Text = (Shove._Convert.StrToDouble(strMoney, 0) == 0) ? "0.00" : Shove._Convert.StrToDouble(strMoney, 0).ToString("N");
        }
    }

    protected void g_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
        {
            for (int i = 3; i <= 3; i++)
            {
                double money = Shove._Convert.StrToDouble(e.Item.Cells[i].Text, 0);
                e.Item.Cells[i].Text = (money == 0) ? "" : money.ToString("N");
            }

            string type = e.Item.Cells[5].Text;
            if (Shove._Convert.StrToDouble(type, 0) > 0)
            {
                e.Item.Cells[5].Text = "支付宝支付";
            }
            else
            {
                e.Item.Cells[5].Text = "银联支付";
            }


            string sequenceNumber = e.Item.Cells[0].Text.ToString();
            if (Shove._Convert.StrToInt(sequenceNumber, 0) >= 10)
            {
                e.Item.Cells[0].Text = "0" + sequenceNumber;
            }
            else
            {
                e.Item.Cells[0].Text = "00" + sequenceNumber;
            }
        }
    }
}
